<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:p="http://primefaces.org/ui"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets">
<ui:composition template="/pages/home.xhtml">
	<ui:define name="title">
		<h:outputText value="#{text.titCargo}" />
	</ui:define>
	<ui:define name="content">
		<p:fieldset id="fieldSetCargo" binding="#{cargoController.fieldSetCargo}">
			<h:inputHidden id="cargoId"	value="#{cargoController.selectedCargo.idCargo}" />
			<h:panelGrid id="pnlFields" columns="3">

				<h:outputLabel for="cod" value="#{text.lblCargoCodigo}" />
				<p:inputText id="cod" size="15" maxlength="10"
					value="#{cargoController.selectedCargo.idCargo}" readonly="true"
					styleClass="inputfield-readonly"/>
				<p:message for="cod" />
				
				<h:outputLabel for="desc" value="#{text.lblCargoDesc}" />
				<p:inputText id="desc" required="true" size="50" maxlength="30"
					requiredMessage="#{message.requiredCargoDesc}"
					value="#{cargoController.selectedCargo.descCargo}" />
				<p:message for="desc" />

			</h:panelGrid>

			<p:separator />

			<p:commandButton id="btnNew" value="#{text.btnNew}"
				icon="ui-icon-document" actionListener="#{cargoController.newCargo}"
				immediate="true" update=":frmContent:fieldSetCargo"
				onclick="grdCargo.unselectAllRows();clearRadioDataTable();"/>
			<p:commandButton id="btnSave" value="#{text.btnSave}"
				icon="ui-icon-disk"
				update=":frmContent:fieldSetCargo, :frmContent:grdCargo"
				actionListener="#{cargoController.saveCargo}"
				process=":frmContent:fieldSetCargo" />
			<p:commandButton id="btnDelete" value="#{text.btnDelete}"
				icon="ui-icon-trash" onclick="dialogDelete.show()"
				binding="#{cargoController.btnDelete}" disabled="true" global="false"/>
			<p:confirmDialog id="dlgConfirmDelete" widgetVar="dialogDelete"
				closable="true" severity="info" appendToBody="true"
				header="#{text.dlgConfirm}" message="#{message.confirmDelete}"
				width="400">
				<p:commandButton id="btnConfirmDelete"
					actionListener="#{cargoController.deleteCargo}"
					value="#{text.btnConfirm}" icon="ui-icon-check"
					oncomplete="dialogDelete.hide()"
					update=":frmContent:fieldSetCargo, :frmContent:grdCargo" />
				<p:commandButton id="btnDeclineDelete" onclick="dialogDelete.hide()"
					value="#{text.btnCancel}" icon="ui-icon-cancel" global="false"/>
			</p:confirmDialog>

		</p:fieldset>

		<p:spacer height="25" />

		<p:dataTable id="grdCargo" var="cargo"
			value="#{cargoController.cargoDataModel}" widgetVar="grdCargo"
			emptyMessage="#{text.grdEmpty}"
			selection="#{cargoController.selectedCargo}" paginator="true"
			rows="10" rowsPerPageTemplate="10,25,50"
			paginatorTemplate=" {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
			sortBy="#{cargo.descCargo}">

			<p:ajax event="rowSelect" update=":frmContent:fieldSetCargo"
				listener="#{cargoController.selectCargo}"  />

			<p:column selectionMode="single" style="width:18px" />
			<p:column id="colCargoCod" headerText="#{text.lblCargoCodigo}" sortBy="#{cargo.idCargo}"
				style="width:100px;">
				<h:outputText value="#{cargo.idCargo}" styleClass="cell-align-right"/>
			</p:column>
			<p:column id="colCargoDesc" headerText="#{text.lblCargoDesc}" sortBy="#{cargo.descCargo}">
				<h:outputText value="#{cargo.descCargo}" />
			</p:column>
		</p:dataTable>

	</ui:define>
</ui:composition>
</html>